package com.ihr360.expr.function.excel;


import com.ihr360.expr.ExprException;
import com.ihr360.expr.ExprString;
import com.ihr360.expr.context.IEvaluationContext;
import com.ihr360.expr.core.AbstractFunction;
import com.ihr360.expr.core.Expr;
import com.ihr360.expr.core.ExprNumber;
import com.ihr360.expr.utils.ExprUtils;


public class CONCATENATE extends AbstractFunction
{
    public Expr evaluate(IEvaluationContext context, Expr[] args)
            throws ExprException {
        assertMinArgCount(args, 1);
        StringBuilder sb = new StringBuilder();
        for (Expr a : args) {
            a = ExprUtils.evalArg(context, a);
            if (a instanceof ExprString) {
                sb.append(((ExprString) a).str);
            } else if (a instanceof ExprNumber) {
                sb.append(a.toString());
            }
        }
        return new ExprString(sb.toString());
    }
}
